From: Florian Müllner Date: Thu, 6 Oct 2011 00:47:18 +0000 (+0200) Subject: user-menu: Restore previous session presence at startup X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~7485 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=2947b921489937e6fb8ea8d9634510585b78bcc0;p=gnome-shell.git user-menu: Restore previous session presence at startup Save the session presence in GSettings and restore it on startup. https://bugzilla.gnome.org/show_bug.cgi?id=659021 --- diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in index a848818d2..82b0c331d 100644 --- a/data/org.gnome.shell.gschema.xml.in +++ b/data/org.gnome.shell.gschema.xml.in @@ -54,6 +54,10 @@ 0 <_summary> + + 0 + <_summary> + diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 85d98028e..d6e30af78 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -158,10 +158,11 @@ IMStatusChooserItem.prototype = { Lang.bind(this, this._changeIMStatus)); this._presence = new GnomeSession.Presence(); - this._presence.getStatus(Lang.bind(this, this._sessionStatusChanged)); this._presence.connect('StatusChanged', Lang.bind(this, this._sessionStatusChanged)); + this._sessionPresenceRestored = false; + this._imPresenceRestored = false; this._currentPresence = undefined; this._accountMgr = Tp.AccountManager.dup() @@ -267,12 +268,20 @@ IMStatusChooserItem.prototype = { }, _IMStatusChanged: function(accountMgr, presence, status, message) { + if (!this._imPresenceRestored) + this._imPresenceRestored = true; + if (presence == this._currentPresence) return; this._currentPresence = presence; this._setComboboxPresence(presence); + if (!this._sessionPresenceRestored) { + this._presence.getStatus(Lang.bind(this, this._sessionStatusChanged)); + return; + } + if (presence == Tp.ConnectionPresenceType.AVAILABLE) this._presence.setStatus(GnomeSession.PresenceStatus.AVAILABLE); @@ -349,6 +358,20 @@ IMStatusChooserItem.prototype = { }, _sessionStatusChanged: function(sessionPresence, sessionStatus) { + if (!this._imPresenceRestored) + return; + + if (!this._sessionPresenceRestored) { + let savedStatus = global.settings.get_int('saved-session-presence'); + if (sessionStatus != savedStatus) { + this._presence.setStatus(savedStatus); + return; + } + this._sessionPresenceRestored = true; + } + + global.settings.set_int('saved-session-presence', sessionStatus); + let [presence, s, msg] = this._accountMgr.get_most_available_presence(); let newPresence, status;